<template>
  <div class="login-container">
    <div class="login">
      <div class="login-logo">
        <img
          src="http://likede2-admin.itheima.net/img/logo.595745bd.png"
          alt=""
        >
      </div>
      <el-form
        ref="loginForm"
        :model="loginForm"
        status-icon
        :rules="rules"
        class="list"
      >
        <el-form-item prop="username">
          <i class="el-icon-mobile-phone" />
          <el-input
            v-model="loginForm.username"
            autocomplete="off"
            placeholder="请输入账号"
            style="width:430px"
          />
        </el-form-item>
        <el-form-item prop="password">
          <i class="el-icon-lock" />
          <el-input
            v-model="loginForm.password"
            type="password"
            autocomplete="off"
            show-password
            placeholder="请输入密码"
            style="width:430px"
          />
        </el-form-item>
        <el-form-item class="el-form-item__content" prop="code">

          <div class="el-row is-justify-space-between el-row--flex">

            <i class="el-icon-check" />

            <div class="el-col el-col-17">
              <el-input v-model="loginForm.code" placeholder="请输入验证码" />
            </div>

            <div class="el-col el-col-7">
              <img
                src="
              https://likede2-java.itheima.net/api/user-service/user/imageCode/jB6Ldwujf8431z3s4Pk30K1EP89LRPKa "
                alt=""
              >
            </div>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            style="width: 446px;height:50px"
            @click="submitForm"
          >登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
// import { validUsername } from '@/utils/validate'

export default {
  name: 'Login',
  data() {
    return {
      loginForm: {
        username: '',
        password: '',
        code: ''
      },
      rules: {
        username: [
          { required: true, message: '请输入账号', trigger: 'blur' },
          {
            pattern: /^[\w-]{5,16}$/,
            message: '请输入正确的用户名',
            trigger: 'blur'
          }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          {
            min: 6,
            max: 16,
            message: '密码长度应该为6-16位之间',
            trigger: 'blur'
          }
        ],
        code: [
          { required: true, message: '请输入验证码', trigger: 'blur' },
          {
            min: 4,
            max: 4,
            message: '请输入4位数验证码',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  methods: {
    submitForm() {}
  }
}
</script>
<style lang="scss">
/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */

$bg: #283443;
$light_gray: #999;
$cursor: #333;

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .login-container .el-input input {
    color: $cursor;
  }
}

/* reset element-ui css */
.login-container {
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;

    input {
      background: transparent;
      border: 0px;
      border-radius: 0px;
      padding: 12px 5px 12px 25px;
      color: $light_gray;
      height: 47px;
      caret-color: $cursor;

      &:-webkit-autofill {
        box-shadow: 0 0 0px 1000px $bg inset !important;
        -webkit-text-fill-color: $cursor !important;
      }
    }
  }

  .el-form-item {
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 5px;
    color: #454545;
    height: 50px;
  }
  .el-button {
    background-color: #6579ed;
  }
}
</style>

<style lang="scss" scoped>
$bg: #fff;
$dark_gray: #889aa4;
$light_gray: #eee;

.login-container {
  min-height: 100%;
  width: 100%;
  background-color: $bg;
  overflow: hidden;

  .login-form {
    position: relative;
    width: 520px;
    max-width: 100%;
    padding: 160px 35px 0;
    margin: 0 auto;
    overflow: hidden;
  }

  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  .svg-container {
    padding: 6px 5px 6px 15px;
    color: $dark_gray;
    vertical-align: middle;
    width: 30px;
    display: inline-block;
  }

  .title-container {
    position: relative;

    .title {
      font-size: 26px;
      color: $light_gray;
      margin: 0px auto 40px auto;
      text-align: center;
      font-weight: bold;
    }
  }

  .show-pwd {
    position: absolute;
    right: 10px;
    top: 7px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
    user-select: none;
  }
}
.login-container {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-image: url("http://likede2-admin.itheima.net/img/background.be4fae7d.png");
  background-repeat: no-repeat;
  background-size: cover;

  .login {
    position: relative;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 76px 35px 0;
    width: 518px;
    height: 388px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #333;
    margin: 0 auto;
    .login-logo {
      position: absolute;
      width: 96px;
      height: 96px;
      top: -46px;
      left: 50%;
      margin-left: -48px;
      img {
        width: 96px;
        height: 96px;
      }
    }
  }
}
.el-icon-mobile-phone,
.el-icon-lock{
  transform: translateX(15px);
}
.el-form-item__content{
  position: relative;
  line-height: 47px;
  .el-row--flex.is-justify-space-between{
    width: 444px;
    height: 47px;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
   }
}
.el-icon-check{
  width: 14px;
  height: 14px;
  transform: translate(15px,15px);
}
</style>
